Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Simple ASP to display files in a directory with a webview

Total Hit ( 5576)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


This is a Really cool page. I use this for my test site.

  • Have lots of ASP Pages?
  • Hate updating links manually?
    Let this page do the work for you!

  • Click here to copy the following block
    <%
    showdirs=1

    Function ShowImageForType(strName)
       Dim strTemp

       strTemp = strName
       If strTemp <> "dir" Then
           strTemp = LCase(Right(strTemp, Len(strTemp) - InStrRev(strTemp, ".", -1, 1)))
       End If
       
       Select Case strTemp
           Case "asp"
               strTemp = "asp"
           Case "dir"
               strTemp = "dir"
           Case "htm", "html"
               strTemp = "htm"
           Case "gif", "jpg"
               strTemp = "img"
           Case "txt"
               strTemp = "txt"
           Case Else
               strTemp = "misc"
       End Select


       strTemp = "<IMG SRC=""/images/dir_" & strTemp & ".gif"" WIDTH=16 HEIGHT=16 BORDER=0>"

       ShowImageForType = strTemp
    End Function
    'That's it for functions on this one!
    %>


    <%' Now to the Runtime code:
    Dim strPath  'Path of directory to show
    Dim objFSO  'FileSystemObject variable
    Dim objFolder 'Folder variable
    Dim objItem  'Variable used to loop through the contents of the folder

    strPath = "./"
    requestedPath = request.querystring("path")
    if requestedPath <> "" then strPath = requestedPath

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))

    %>
    <html><head>
    <link rel="stylesheet" type="text/css" href="/include/kb1.css">
    </head>

    Contents of <B><%= strPath %></B><BR>


    <BR>

    <TABLE BORDER="5" BORDERCOLOR="green" CELLSPACING="0" CELLPADDING="2">
       <TR BGCOLOR="#006600">
           <TD><FONT COLOR="#FFFFFF"><B>File Name:</B></FONT></TD>
           <TD><FONT COLOR="#FFFFFF"><B>File Size (bytes):</B></FONT></TD>
           <TD><FONT COLOR="#FFFFFF"><B>Date Created:</B></FONT></TD>
           <TD><FONT COLOR="#FFFFFF"><B>File Type:</B></FONT></TD>
       </TR>
    <%

    if showdirs=1 then
    For Each objItem In objFolder.SubFolders
       ' Deal with the stupid VTI's that keep giving our visitors 404's
       If InStr(1, objItem, "_vti", 1) = 0 Then
       %>
       <TR BGCOLOR="#CCFFCC">
           <TD ALIGN="left" ><%= ShowImageForType("dir") %>&nbsp;<A HREF="<%= strPath & objItem.Name %>"><%= objItem.Name %></A></TD>
           <TD ALIGN="right">N/A</TD>
           <TD ALIGN="left" ><%= objItem.DateCreated %></TD>
           <TD ALIGN="left" ><%= objItem.Type %></TD>
       </TR>
       <%
       End If
    Next 'objItem
    End If ' showdirs

    For Each objItem In objFolder.Files
    %>
       <TR BGCOLOR="#CCFFCC">
           <TD ALIGN="left" ><%= response.write("  ") %>&nbsp;<A HREF="<%= strPath & objItem.Name %>"><%= objItem.Name %></A></TD>
           <TD ALIGN="right"><%= objItem.Size %></TD>
           <TD ALIGN="left" ><%= objItem.DateCreated %></TD>
           <TD ALIGN="left" ><%= objItem.Type %></TD>
       </TR>
    <%
    Next 'objItem

    Set objItem = Nothing
    Set objFolder = Nothing
    Set objFSO = Nothing

    %>
    </TABLE>
    </html>


    Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

    Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
    View all (893) submissions by this author  (Birth Date : 7/14/1981 )


    Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

    © 2008 BinaryWorld LLC. All rights reserved.